package com.heima.admin.controller.v1;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {
    @Autowired
    private IWemediaClient iChannelClient;

    @PostMapping("/list")
    public PageResponseResult list(@RequestBody WmChannelDto wmChannelDto) {

        return iChannelClient.list(wmChannelDto);
    }


    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        return iChannelClient.saveChannel(wmChannel);
    }


    @GetMapping("/del/{id}")
    public ResponseResult deleteChannelID(@PathVariable Integer id){
        System.out.println(id);
        return iChannelClient.deleteChannelByid(id);
    }


    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel){
        return iChannelClient.updateChannelByid(wmChannel);
    };
}
